﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;

namespace PHP.Koc_Tomo.Testing
{
    public class XML2Object
    {
        public static object Convert(string XML, Type type)
        {
            var b = new System.Xml.Serialization.XmlSerializer(type);

            byte[] byteArray = Encoding.ASCII.GetBytes(XML);
            MemoryStream stream = new MemoryStream( byteArray );

            var c = b.Deserialize(stream);

            return c;
        }

        public static List<object> Convert(string XML, Type type, string listRootElement)
        {
            var b = new System.Xml.Serialization.XmlSerializer(type, , new XmlRootAttribute(listRootElement));

            byte[] byteArray = Encoding.ASCII.GetBytes(XML);
            MemoryStream stream = new MemoryStream(byteArray);

            var c = b.Deserialize(stream);

            return c;
        }


    }
}
